import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: '/',
            name: 'home',
            component: () => import('../views/HomeView.vue')
        },
        {
            path: '/login',
            name: 'login',
            component: () => import('../views/LoginView.vue')
        },
        {
            path: '/weekDetail',
            name: 'weekDetail',
            component: () => import('../views/StockDetailView.vue')
        },
        {
            path: '/stockDetail',
            name: 'stockDetail',
            component: () => import('../views/StockDetailView.vue')
        },
        {
            path: '/multi',
            name: 'multi',
            component: () => import('../views/MultiView.vue')
        },
        {
            path: '/stockHold',
            name: 'stockHold',
            component: () => import('../views/StockHoldView.vue')
        },
        {
            path: '/industry',
            name: 'industry',
            component: () => import('../views/IndustryView.vue')
        },
        {
            path: '/industry/p',
            name: 'industry-p',
            component: () => import('../components/industry/Panorama.vue')
        },
        {
            path: '/lpDetail',
            name: 'lpDetail',
            component: () => import('../views/LpDetailView.vue')
        },
        {
            path: '/finance',
            name: 'finance',
            component: () => import('../views/FinanceView.vue')
        },
        {
            path: '/wugu',
            name: 'wugu',
            component: () => import('../views/WuguView.vue')
        },
        {
            path: '/monitor',
            name: 'monitor',
            component: () => import('../views/MonitorView.vue')
        },
        {
            path: '/stat/m',
            name: 'stat-m',
            component: () => import('../components/stat/MonthPct.vue')
        },
        {
            path: '/rank',
            name: 'rank',
            component: () => import('../views/TradingRankView.vue')
        },
        {
            path: '/gb',
            name: 'gb',
            component: () => import('../views/GBStaView.vue')
        },
        {
            path: '/dailyGB',
            name: 'dailyGB',
            component: () => import('../views/DailyGBStaView.vue')
        },
        {
            path: '/roll',
            name: 'roll',
            component: () => import('../components/roll/RollDailyCloseEchart.vue')
        },
        {
            path: '/display',
            name: 'display',
            component: () => import('../components/WeekStockPctDisplay.vue')
        },
        {
            path: '/ddisplay',
            name: 'ddisplay',
            component: () => import('../components/DailyStockPctDisplay.vue')
        },
        {
            path: '/compare',
            name: 'compare',
            component: () => import('../components/WeekTwoStockCompare.vue')
        },
        {
            path: '/drawdown',
            name: 'drawdown',
            component: () => import('../components/DailyDrawDownSat.vue')
        },
        {
            path: '/h',
            name: 'h',
            component: () => import('../views/StockHistogramView.vue')
        },
        {
            path: '/math',
            name: 'math',
            component: () => import('../views/MathView.vue')
        },
    ]
})
export default router

export const openNewTableWeekDetail = (stock) => {
  let href = router.resolve({
    path: "/weekDetail",
    query: {
      stock: stock,
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableIndustry = (tag) => {
  let href = router.resolve({
    path: "/industry",
    query: {
      industry: tag,
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableDisplay = (stock, date) => {
  let href = router.resolve({
    path: "/display",
    query: {
        stock: stock,
        date: date
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableDDisplay = (stock, date) => {
  let href = router.resolve({
    path: "/ddisplay",
    query: {
        stock: stock,
        date: date
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableCompare = (stocks) => {
  let href = router.resolve({
    path: "/compare",
    query: {
        stocks: stocks.join(";"),
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableMulti = (stocks) => {
  let href = router.resolve({
    path: "/multi",
    query: {
        stocks: stocks.join(";"),
    }
  }).href
  window.open(href, '_blank');
}

export const openNewTableMean = (stock, date) => {
  let href = router.resolve({
    path: "/roll",
    query: {
        search: 'STOCKS;' + stock,
        sDate: date
    }
  }).href
  window.open(href, '_blank');
}